home *** CD-ROM | disk | FTP | other *** search
/ Commodore 64 Scene Diskmags Assortment / Commodore_CEE_Vol._1_Issue_05_1995_Jack_Vander_White_Disk_2_of_3_Side_A.d64 / basic help < prev    next >
Text File  |  2023-02-26  |  3KB  |  56 lines

  1. From: a2233495@rrz.Uni-Koeln.DE (Joerg Bleimann)
  2.  
  3. I have got a problem with COMMODORE BASIC 2.0: I started programming a text adventure on the C 64 and do not know how to make the computer recognize the latter part of a bipartite command string (for example "TAKE BOTTLE"). How can I search the whole string for empties (" ") to redefine the part right from the empty as a new string? ASC only recognizes the first character of a string, VAL takes only number characters into account... and machine language is all Greek to me! Yet another question: in more modern BASIC dialects, one can avoid the ? after INPUT by typing a comma before the variable; in CBM BASIC 2.0 this would pro- duce a SYNTAX ERROR. Are there any ways to get rid of the question mark using BASIC on the C 64?
  4.  
  5. ---------------
  6. From: Jason <tmr@cosine.demon.co.uk>
  7.  
  8. You need to use the sexy little MID$ command.  Eg:
  9.  
  10. 10 A$="EAT GOLDFISH" 
  11. 20 B$=MID$(A$,5,8) 
  12. 30 PRINT B$
  13.  
  14. Will put just the word GOLDFISH on your screen.
  15.  
  16. The first number specifies where to start from in A$ and the second says how much to take.  You can, therefore use it to scan one character at a time through the string using MID$(A$,T,1) with T as a counter to find the space and then fracture the two halves off thus:
  17.  
  18. 10 INPUT A$                 ;Get a command 
  19. 20 T=1                      ;Reset variable T to scan the string 
  20. 30 L=LEN(A$)                ;Get length of the command string 
  21. 40 IFMID$(A$,T,1)=" "THEN70 ;Read character and compare with space 
  22. 50 T=T+1                    ;Add one to counter 
  23. 60 IFT<=LTHEN40             ;See if counter has passed the end of
  24.                             ; the string 
  25. 70 C$=MID$(A$,1,T-1)        ;C$=COMMAND$ (Get, Go, Etc.) 
  26. 80 O$=MID$(A$,T+1,L-T)      ;O$=OBJECT$  (Banana, North, Etc.) 
  27. 90 PRINTC$:PRINTO$          ;Show the result of this test
  28.  
  29. Since this is an example there is no error trapping for things like incorrect inputs, shifted spaces or having more than two words a line but it should be easy to add that to it!  Hioe that helps!!
  30.  
  31. ----------------------
  32. From: ros@mfltd.co.uk      (Richard Smith)
  33.  
  34.  
  35. 20 FORI=1TOLEN(A$) 
  36. 30 IFMID$(A$,I,1)=" "THENJ=I:I=999 
  37. 40 NEXT 
  38. 50 REM AT THIS POINT IF I=1000 THEN J IS POSITION 
  39.    OF FIRST SPACE ELSE NO SPACE 
  40. 60 REM FOUND
  41.  
  42. >Yet another question: in more modern BASIC dialects, one can avoid the ? after >INPUT by typing a comma before the variable; in CBM BASIC 2.0 this would pro- >duce a SYNTAX ERROR. Are there any ways to get rid of the question mark using >BASIC on the C 64?
  43.  
  44. 10 OPEN1,0 
  45. 20 INPUT#1,A$:PRINT 
  46. 30 PRINT"A$="A$
  47.  
  48. -------------------
  49. From: d95josef@dtek.chalmers.se (Josef Sveningsson)
  50.  
  51. As I remember (it's been a long time since I did this) there are two ways to do this. One is to copy the BASIC rom into ram and change the value of the adress which contains the questionmark. But I wouldn't recomend this if you are programming in BASIC. The way to do it is to open a channel to the keyboard using OPEN. The problem is that I don't remember the exact way to do it, even though it wasn't hard. Well, basically you just open a cannel to the keyboard, read from the channel until you get a 'return' and then close the channel. I think the '64-users- manual' (or whatever it's called) will tell you more about how to open and read from the channel in the right way.
  52.  
  53. --------------------------
  54.  
  55.  
  56.